package org.brunoc.searchstores4j;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.brunoc.searchstores4j.vo.AmericanasStore;
import org.brunoc.searchstores4j.vo.SubmarinoStore;
import org.brunoc.searchstores4j.vo.models.IStoreObject;
import org.brunoc.searchstores4j.vo.models.Product;

import com.googlecode.inutils4j.MyStringUtils;

/**
 * Main class for search tests (visual test)
 * @author Bruno Candido Volpato da Cunha
 *
 */
public class MainTest {
	
	private final static String QUERY = "Xbox+360";
	
	public static void main(String[] args) {

		IStoreObject[] stores = {new SubmarinoStore(), new AmericanasStore()};
		List<Product> productAll = new ArrayList<Product>();
		
		try {
			for (IStoreObject store : stores){
				System.out.println("*** Searching on: " + store.getName());
				List<Product> products = store.makeAndSearch(QUERY);
				productAll = MyStringUtils.mixLists(productAll, products);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		for (Product p : productAll) {
			System.out.println(p.getStore() + " - " + p.getName() + " - " + p.getPrice());
		}
		
	}
}
